package com.esc.service;

import com.esc.mapper.ZixunMapper;
import com.esc.model.Zixun;
import com.esc.server.ZixunServiceApi;
import com.esc.util.PageResult;
import com.esc.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ZixunServiceImpl implements ZixunServiceApi {

    @Autowired
    private ZixunMapper zixunMapper;

    @Override
    public PageResult queryZixunList(PageUtil<Zixun> pageUtil) {
        PageResult page = new PageResult();
        int total  = zixunMapper.queryCont();
        page.setTotal(total);
        List<Zixun> list = zixunMapper.queryZixunList(pageUtil.getStartIndex(),pageUtil.getRows());
        page.setRows(list);
        return page;
    }

    @Override
    public Zixun queryZixunById(@RequestParam("zixunid") Integer zixunid) {
        return zixunMapper.queryZixunById(zixunid);
    }
}
